# -*- coding: utf-8 -*-

from odoo import models, fields, api, modules, _
from odoo.exceptions import UserError

class County(models.Model):
    _name = 'mxbase.county'

    name = fields.Char(required=True, string=u'名称')
    code = fields.Char(required=True, string=u'编码')

    province_id = fields.Many2one('mxbase.province', string=u'省/自治区/直辖市')
    city_id = fields.Many2one('mxbase.city', string=u'市')

    weather_city_id=fields.Char(string=u'墨迹天气城市ID')
    weather_cn_id=fields.Char(string=u'天气城市ID')

    # @api.model
    # def name_search(self, name, args=None, operator='ilike', limit=100):
    #     args = args or []
    #     if name:
    #         args += [('name', operator, name)]
    #     context = self.env.context
    #     if context.get('province_id'):
    #         province = self.env['province'].browse(context.get('province_id'))
    #         if province.no_city:
    #             args += [('id', 'in', province.county_ids.ids)]
    #     records = self.search(args, limit=limit)
    #     return records.name_get()

